/*
 * 类名称:CompanyInfoController.java
 * 包名称:com.lht.admin.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-12-29 14:09:46        ZhengZhanWu     初版做成
 */
package com.lht.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lht.admin.annotation.SysLog;
import com.lht.admin.utils.R;
import com.lht.admin.controller.AbstractController;
import com.lht.admin.entity.CompanyInfoEntity;
import com.lht.admin.service.CompanyInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 公司信息Controller
 *
 * @author ZhengZhanWu
 * @date 2019-12-29 14:09:46
 */
@RestController
@RequestMapping("/companyinfo")
public class CompanyInfoController extends AbstractController {
    @Autowired
    private CompanyInfoService companyInfoService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return R
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("companyinfo:list")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<CompanyInfoEntity> list = companyInfoService.queryAll(params);

        return R.ok().put("list", list);
    }

    /**
     * 分页查询公司信息
     *
     * @param params 查询参数
     * @return R
     */
    @GetMapping("/list")
    @RequiresPermissions("companyinfo:list")
    public R list(@RequestParam Map<String, Object> params) {
        Page page = companyInfoService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("companyinfo:info")
    public R info(@PathVariable("id") Long id) {
        CompanyInfoEntity companyInfo = companyInfoService.getById(id);

        return R.ok().put("companyinfo", companyInfo);
    }

    /**
     * 新增公司信息
     *
     * @param companyInfo companyInfo
     * @return R
     */
    @SysLog("新增公司信息")
    @RequestMapping("/save")
    @RequiresPermissions("companyinfo:save")
    public R save(@RequestBody CompanyInfoEntity companyInfo) {

        companyInfoService.add(companyInfo);

        return R.ok();
    }

    /**
     * 修改公司信息
     *
     * @param companyInfo companyInfo
     * @return R
     */
    @SysLog("修改公司信息")
    @RequestMapping("/update")
    @RequiresPermissions("companyinfo:update")
    public R update(@RequestBody CompanyInfoEntity companyInfo) {

        companyInfoService.update(companyInfo);

        return R.ok();
    }

    /**
     * 根据主键删除公司信息
     *
     * @param ids ids
     * @return R
     */
    @SysLog("删除公司信息")
    @RequestMapping("/delete")
    @RequiresPermissions("companyinfo:delete")
    public R delete(@RequestBody Long[] ids) {
        companyInfoService.deleteBatch(ids);

        return R.ok();
    }
}
